package net.cocotea.sqltoy.lambda.factory.condition.base;

import net.cocotea.sqltoy.lambda.common.SqlCharter;
import net.cocotea.sqltoy.lambda.func.SFunction;
import net.cocotea.sqltoy.lambda.util.ColUtils;
import org.sagacity.sqltoy.utils.StringUtil;

public abstract class BaseConditionAction<T> implements IConditionAction {
    protected final String filed;
    protected final Object value;

    public BaseConditionAction(SFunction<T, ?> function, Object value) {
        String filedName = ColUtils.filedName(function);
        if (StringUtil.isBlank(filedName)) {
            throw new RuntimeException("filed name is blank");
        }
        this.filed = filedName;
        this.value = value;
    }

    @Override
    public String valueName() {
        return this.getClass().getSimpleName() + SqlCharter.UNDERLINE + filed + SqlCharter.UNDERLINE + this.hashCode();
    }
}
